import os
import itchat
import pandas as pd


import numpy as np

try:
    i = 1
    a = 0
    c = i/a
except Exception as e:
    print('======'+str(e))

#s1=np.array([1,2,3,4])
#s2=np.array([5,6,7,8])
#df=pd.DataFrame([s1,s2])
#print(df)


#s1 = pd.Series(np.array([1,2,3,4]))
#s2 = pd.Series(np.array([5,6,7,8]))
#s3 = pd.Series(np.array([9,10,11,12]))
#df = pd.DataFrame({'A':s1,'B':s2,'C':s3})
#df['结果'] = np.where(df.A<3,'小于','大于')
#print(df)

#df=pd.DataFrame({"A":[1,2,3,4],"B":[5,6,7,8],"C":[1,1,1,1]})
#df=df[df.A>0]
#print(df)

#df=pd.DataFrame({"A":[1,2,3,4],"B":[5,6,7,8],"C":[1,1,1,1]})
#df=df.loc[df.A>0]
#print(df)

df = pd.DataFrame({'animal': 'cat dog cat fish dog cat cat'.split(),
                  'size': list('SSMMMLL'),
                  'weight': [8, 10, 11, 1, 20, 12, 12],
                  'adult' : [False] * 5 + [True] * 2});
#列出动物中weight最大的对应size
group=df.groupby("animal").apply(lambda subf: subf['size'][subf['weight'].idxmax()])
print(group)